home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dumpq.zip / DUMPQ.C next >
C/C++ Source or Header  |  1992-01-09  |  2KB  |  87 lines

  1. /*-------------------------------------------------------------------------
  2.  *   dumpq.c - Delete all the jobs in a specified Netware print queue
  3.  *             from the command line
  4.  *
  5.  *    by Glenn Scott (UCLA HUP / Info Services)
  6.  *       Internet:  glenn@lands.sscnet.ucla.edu
  7.  *       CIS:       71620,1521
  8.  *
  9.  *   10/18/91
  10.  *
  11.  *   Syntax:  DUMPQ queuename
  12.  *
  13.  *            Obviously, you have to have the proper rights to delete
  14.  *            a bunch of jobs from a queue.
  15.  *
  16.  *   Recompilation requires Netware C Interface for DOS, v1.2
  17.  *
  18.  *   Notes:  This program deletes all the jobs in the queue that were
  19.  *           present when the queue job list is retrieved.  In other
  20.  *           words, jobs could be added while DUMPQ is deleting
  21.  *           which would be missed, and jobs could print and thus
  22.  *           leave the queue before DUMPQ can actually delete them.
  23.  *
  24.  */
  25.  
  26.  
  27. #include <stdio.h>
  28. #include <nit.h>
  29. #include <niterror.h>
  30.  
  31. main( int argc, char *argv[] )
  32. {
  33.   void usage();
  34.   int  rc;
  35.   long queueID;
  36.   WORD numJobs;
  37.   WORD jobList[250];
  38.   int  i;
  39.   int  numDel = 0;
  40.  
  41.   printf("DUMPQ Queue Dump Utility\n");
  42.  
  43.   if ( !GetDefaultConnectionID() )
  44.      {
  45.      printf("This program requires Netware 2.1x or higher.\n");
  46.      exit(1);
  47.      }
  48.  
  49.  
  50.   if ( argc < 2 ) {
  51.      usage();
  52.      exit(1);
  53.      }
  54.  
  55.  
  56.   if ( rc = GetBinderyObjectID( argv[1], OT_PRINT_QUEUE, &queueID ) != SUCCESSFUL ) {
  57.      printf( "Error getting print queue object ID (%d)\n", rc );
  58.      exit(1);
  59.      }
  60.  
  61.   if ( rc = GetQueueJobList( queueID, &numJobs, jobList, 250 ) != SUCCESSFUL ) {
  62.      printf( "Error getting job list (%d)\n", rc );
  63.      exit(1);
  64.      }
  65.  
  66.   if ( numJobs <= 0 ) {
  67.      printf( "No jobs in queue %s to delete!\n", argv[1] );
  68.      exit(0);
  69.      }
  70.  
  71.   printf( "Deleting %d job(s) from queue %s...\n", numJobs, argv[1] );
  72.  
  73.   for ( i = 0; i < numJobs; i++ )
  74.      if ( RemoveJobFromQueue( queueID, jobList[i] ) == SUCCESSFUL )
  75.         numDel++;
  76.  
  77.   printf( "%d job(s) deleted from queue %s.\n", numDel, argv[1] );
  78.   exit(0);
  79. }
  80.  
  81. void usage()
  82. {
  83.   printf("Deletes jobs from a specified print queue.\n\n");
  84.   printf("\tUsage:  dumpq printQueue\n\n");
  85.   printf("Ex:  dumpq BILL_LASERJET\n");
  86. }
  87.